<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI 选择（Selectable） - 序列化</title>
  <link rel="stylesheet" href="script/jquery-ui.1.10.4.css">  <!-- 注意顺序-->
  <script src="script/jquery-1.10.min.js"></script>
  <script src="script/jquery-ui.1.10.4.min.js"></script>
  <link rel="stylesheet" href="jqueryui/style.css">
 
  <style>
  #feedback { font-size: 1.4em; }
  /*鼠标按住时的颜色*/
  #selectable .ui-selecting { background: #FECA40; }
  /*选中的样式  */
  #selectable .ui-selected { background: #F39814; color: white; }
  
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
  </style>
  <script>
  $(function() {
    $( "#selectable" ).selectable({
      stop: function() {  //stop  在选择操作结尾触发

        var result = $( "#select-result" ).empty();  //清空显示  index的span
        $( ".ui-selected").each(function(index,obj) {//遍历选中过的
          console.log($(this).text())
          console.log(index,obj)
          // var index = $( "#selectable li" ).index( this );
          result.append( " @" + ( $(this).text() ) );
        });
      
      }
    });
  });
  </script>
</head>
<body>
 
<p id="feedback">
<span>您已经选择了：</span> <span id="select-result">无</span>
</p>
 <!-- 按住ctrl多选 -->
<ol id="selectable"> 
  <li class="ui-widget-content">Item 1</li>
  <li class="ui-widget-content">Item 2</li>
  <li class="ui-widget-content">Item 3</li>
  <li class="ui-widget-content">Item 4</li>
  <li class="ui-widget-content">Item 5</li>
  <li class="ui-widget-content">Item 6</li>
</ol>
 
 
</body>
</html>